<?php
require_once 'init.php';

if( isset($_REQUEST['mode']) )
{
	$mode = $_REQUEST['mode'];
	
	switch( $mode )
	{
		case 'fuel-types':
			outputQuery("SELECT typeID, typeName, mass, volume, basePrice, iconID FROM invTypes WHERE typeID IN (SELECT DISTINCT resourceTypeID FROM `invControlTowerResources` WHERE 1)");
			break;

		case 'towers':
			outputQuery("SELECT typeID, typeName, mass, volume, basePrice, capacity FROM invTypes WHERE groupID = 365 AND published = 1");
			break;
			
		case 'tower-fuel':
			outputQuery("SELECT controlTowerTypeID, resourceTypeID, purpose, purposeText, quantity, minSecurityLevel, factionID FROM invControlTowerResources JOIN invControlTowerResourcePurposes USING(purpose) JOIN invTypes ON controlTowerTypeID = typeID WHERE invTypes.published = 1;");
			break;

		case 'type-attributes':
			$prefixSql = '';
			$params = array();
			if( isset($_REQUEST['typeId']) )
			{
				$prefixSql = ' AND dgmTypeAttributes.typeID = ?';
				$params[] = $_REQUEST['typeId'];
			}
			outputQuery("SELECT attributeName, displayName, valueInt, valueFloat FROM dgmAttributeTypes, dgmTypeAttributes WHERE dgmAttributeTypes.attributeID = dgmTypeAttributes.attributeID" . $prefixSql, $params);
			break;
	}
}